<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>班级管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function copy(oldTerm,newTerm)
		{
			var oldTermId = document.getElementById(oldTerm).value;
			var oldTermName = $("#"+oldTerm).find("option:selected").html();
			var newTermId = document.getElementById(newTerm).value;
			
			if(!oldTermId)
			{
				alert("您选择要复制的学期。");
				return;
			}
			if(!newTermId)
			{
				alert("您选择要复制到的新学期。");
				return;
			}
			if(oldTermId == newTermId)
			{
				alert("您选择的老学期和新学期是同一个学期，请确认。");
				return;
			}
			if(confirm("确定将所选学期的课程复制到新学期吗？"))
			{
				location = "${ctx}/ems/emsCourse/copyCourse?termId=" + oldTermId + "&newTerm=" + newTermId + "&termName=" + oldTermName;
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ems/emsCourse/copy">班级列表</a></li>
		<%-- <shiro:hasPermission name="ems:emsCourse:edit"><li><a href="${ctx}/ems/emsCourse/form">班级添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="emsCourse" action="${ctx}/ems/emsCourse/copy" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<%-- <li><label>班级代码：</label>
				<form:input path="code" htmlEscape="false" maxlength="8" class="input-medium"/>
			</li>
			<li><label>班级名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li> --%>
			<li><label>所属学期：</label>
				<%-- <form:select path="term.id" id="termId" class="input-medium">
					<option value="">---请选择---</option>
					<c:forEach items="${terms }" var="term" varStatus="stat">
						<form:option value="${term.id }">${term.name }</form:option>
					</c:forEach>
				</form:select> --%>
				
				<select name="term.id" id="termId" class="input-medium">
					<option value="">---请选择---</option>
					<c:forEach items="${terms }" var="term" varStatus="stat">
						<option ${termId eq term.id?'selected':''} value="${term.id }">${term.name }</option>
					</c:forEach>
				</select>
				
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			
			<li class="btns"></li>
			
			<li><label>复制到：</label>
				<form:select path="" id="newTerm" class="input-medium">
					<option value="">---请选择---</option>
					<c:forEach items="${terms }" var="term" varStatus="stat">
						<form:option value="${term.id }">${term.name }</form:option>
					</c:forEach>
				</form:select>
			</li>
			
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" value="复制" onclick="copy('termId','newTerm');"/></li>
			 <font color="red" style="float: left;line-height: 40px;font-size: 18px;">
			 	<c:if test="${rs eq 'yes' }">
				 	复制成功
				</c:if>
				<c:if test="${rs eq 'no' }">
				 	复制失败
				</c:if>
			 </font>
			 
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>班级代码</th>
				<th>班级名称</th>
				<th>所属学期</th>
				<th>所属部门</th>
				<th>所属专业</th>
				<th>学时</th>
				<th>学费</th>
				<th>统一折扣</th>
				<th>招生对象</th>
				<th>招生人数</th>
				<th>教室</th>
				<th>开课时间</th>
				<th>上课时间</th>
				<th>任课教师</th>
				<th>班级类型</th>
				<th>是否启用</th>
				<th>修改时间</th>
				<th>备注</th>
				<%-- <shiro:hasPermission name="ems:emsCourse:edit"><th>操作</th></shiro:hasPermission> --%>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="emsCourse">
			<tr>
				<td><a href="${ctx}/ems/emsCourse/form?id=${emsCourse.id}">
					${emsCourse.code}
				</a></td>
				<td>
					${emsCourse.name}
				</td>
				<td>
					${emsCourse.term.name}
				</td>
				<td>
					${emsCourse.major.dept.name}
				</td>
				<td>
					${emsCourse.major.name}
				</td>
				<td>
					${emsCourse.classHours}
				</td>
				<td>
					${emsCourse.fee}
				</td>
				<td>
					${emsCourse.discount}
				</td>
				<td>
					${emsCourse.face}
				</td>
				<td>
					${emsCourse.num}
				</td>
				<td>
					${emsCourse.classroom.name}
				</td>
				<td>
					<fmt:formatDate value="${emsCourse.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${emsCourse.classTime}
				</td>
				<td>
					${emsCourse.teacher.name}
				</td>
				<td>
					${emsCourse.type}
				</td>
				<td>
					${fns:getDictLabel(emsCourse.status, 'yes_no', '')}
				</td>
				<td>
					<fmt:formatDate value="${emsCourse.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${emsCourse.remarks}
				</td>
				<%-- <shiro:hasPermission name="ems:emsCourse:edit"><td>
    				<a href="${ctx}/ems/emsCourse/form?id=${emsCourse.id}">修改</a>
					<a href="${ctx}/ems/emsCourse/delete?id=${emsCourse.id}" onclick="return confirmx('确认要删除该班级吗？', this.href)">删除</a>
				</td></shiro:hasPermission> --%>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>